package com.zjapl.web.action;


import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.zjapl.web.action.vo.Employee;
import com.zjapl.web.service.LoginService;
import com.zjapl.web.service.impl.LoginServiceImpl;

import com.zjapl.web.util.aes.AES;
/** 
 * @author 作者:方武斌    E-mail: fangwb@zjapl.com
 * @version 创建时间：2013-1-10 上午10:00:12 
 * 类说明 
 */
public class LoginAction extends ActionSupport{
     /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	LoginService empService=new LoginServiceImpl();
    private Employee emp=new Employee();
    private String password;
    
    
	
	/**  
	 * 获取password  
	 * @return password   
	 */
	public String getPassword() {
		return password;
	}
	/**  
	 * 设置password  
	 * @param password password  
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	/**  
	 * 获取emp  
	 * @return emp   
	 */
	public Employee getEmp() {
		return emp;
	}
	/**  
	 * 设置emp  
	 * @param emp emp  
	 */
	public void setEmp(Employee emp) {
		this.emp = emp;
	}
    
public String execute() throws Exception {
	String Key="http://www.zjapl.com";
	String encryptResult=AES.encrypttoStr(password, Key);
		emp.setPassword(encryptResult);
		
		if(empService.Login(emp)!=null){
			    emp.setEmp_id(empService.Login(emp).getEmp_id());
				emp.setEmp_name(empService.Login(emp).getEmp_name());
	            emp.setPhoto_add(empService.Login(emp).getPhoto_add());
				ActionContext.getContext().getSession().put("emp_id", empService.Login(emp).getEmp_id()); 
	            return SUCCESS;
		}		   
        return ERROR;		
	}
}
